program Removal;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement = ^element;
  element = record
    value: integer;
    next: pelement;
  end;
procedure AddToBegin (var head: pelement; num: integer);
  var
    tmp: pelement;
  begin
    tmp:= head;
    new(head);
    head^.value:= num;
    head^.next:= tmp;
  end;

 procedure AddToEnd (var head: pelement; num: integer);
  var
    current: pelement;

  begin
    if(head<>nil) then
    begin
      current:=head;
      while(current^.next<>nil) do
        current:=current^.next;
      new(current^.next);
      current^.next^.next:=nil;
      current^.next^.value:=num;
    end else
    begin
      AddToBegin(head,num);
    end;
  end;

function DeleteFromBegin(var head: pelement): integer;
  var
    tmp: pelement;
  begin
    if (head<>nil) then
    begin
      tmp:= head^.next;
      dispose(head);
      head:= tmp;
    end;
  end;
procedure DeleteFromEnd(head: pelement);
  var
    current, tmp: pelement;
  begin
    if (head<>nil) and (head^.next<>nil) then
    begin
      current:= head;
      if current^.next^.next<>nil then
      begin
        current:= current^.next;
      end else begin
        tmp:= nil;
        dispose(current^.next^.next);
        current^.next:= tmp;
      end;
    end;
  end;
procedure PrintList(head: pelement);
  var
    current: pelement;
  begin
    current:= head;
    while (current<>nil) do
    begin
      writeln(current^.value);
      current:=current^.next;
    end;
  end;
procedure Change2Elems(head:pelement; n,k:integer);
  var
    element1,element2: pelement;
    i, tmp:integer;
   begin
      element2:=head;
      for i:=2 to n do begin
        element2:=element2^.next;
      end;
      element1:=head;
      for i:=2 to k do begin
        element1:=element1^.next;
      end;
      tmp:=element1^.value;
      element1^.value:=element2^.value;
      element2^.value:=tmp;

   end;
procedure Inverse( head:pelement; n:integer);
   var
     i:integer;
   begin
     for i:=1 to (n div 2) do  Change2Elems(head, i, n-i+1);
   end;

var
  i, n, num: integer;
  fin: textfile;
  head, tmp, current: pelement;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  readln(fin, n);
  for i := 1 to n do
  begin
    readln(fin, num) ;
   AddToEnd(current, num);
  end;
  PrintList(current);
  writeln;
  Inverse(current,n);
  PrintList(current);
  readln;



end.

